package cn.itcast.demo4;

import org.junit.Test;

public class Demo 
{
	@Test
	public void test1()
	{
		// 应用类加载器--java
		ClassLoader cl1 = Demo.class.getClassLoader();
		System.out.println(cl1);//sun.misc.Launcher$AppClassLoader@18b4aac2
		//扩展类加载器--java
		ClassLoader cl2 = sun.net.spi.nameservice.dns.DNSNameService.class.getClassLoader();
		System.out.println(cl2);//sun.misc.Launcher$ExtClassLoader@3f99bd52
		
		// 引导类加载器--C语言
		ClassLoader cl3 = String.class.getClassLoader();
		System.out.println(cl3);//null
		//返回的是语言的东西，所有返回的是null
	}

	@Test
    public void test2()
    {
        // 应用类加载器--java
        ClassLoader appClassLoader = Demo.class.getClassLoader();
        System.out.println(appClassLoader);
        //扩展类加载器--java
        ClassLoader extClassLoader = appClassLoader.getParent();
        System.out.println(extClassLoader);
        //引导类加载器--PlatformClassLoader 的父加载器是BootStrap.它是c++实现的,返回null
        ClassLoader parent = extClassLoader.getParent();
        System.out.println(parent);
    }
}
